package com.hjm.project.BusinessInfo.BusinessInfo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.BusinessInfo.BusinessInfo.domain.BusinessInfo;
import com.hjm.project.BusinessInfo.BusinessInfo.service.IBusinessInfoService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 图片Controller
 * 
 * @author BusinessInfo
 * @date 2020-11-30
 */
@Controller
@RequestMapping("/BusinessInfo/BusinessInfo")
public class BusinessInfoController extends BaseController
{
    private String prefix = "BusinessInfo/BusinessInfo";

    @Autowired
    private IBusinessInfoService businessInfoService;

    @RequiresPermissions("BusinessInfo:BusinessInfo:view")
    @GetMapping()
    public String BusinessInfo()
    {
        return prefix + "/BusinessInfo";
    }

    /**
     * 查询图片列表
     */
    @RequiresPermissions("BusinessInfo:BusinessInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BusinessInfo businessInfo)
    {
        startPage();
        List<BusinessInfo> list = businessInfoService.selectBusinessInfoList(businessInfo);
        return getDataTable(list);
    }

    /**
     * 导出图片列表
     */
    @RequiresPermissions("BusinessInfo:BusinessInfo:export")
    @Log(title = "图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BusinessInfo businessInfo)
    {
        List<BusinessInfo> list = businessInfoService.selectBusinessInfoList(businessInfo);
        ExcelUtil<BusinessInfo> util = new ExcelUtil<BusinessInfo>(BusinessInfo.class);
        return util.exportExcel(list, "BusinessInfo");
    }

    /**
     * 新增图片
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存图片
     */
    @RequiresPermissions("BusinessInfo:BusinessInfo:add")
    @Log(title = "图片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BusinessInfo businessInfo)
    {
        return toAjax(businessInfoService.insertBusinessInfo(businessInfo));
    }

    /**
     * 修改图片
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BusinessInfo businessInfo = businessInfoService.selectBusinessInfoById(id);
        mmap.put("businessInfo", businessInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存图片
     */
    @RequiresPermissions("BusinessInfo:BusinessInfo:edit")
    @Log(title = "图片", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BusinessInfo businessInfo)
    {
        return toAjax(businessInfoService.updateBusinessInfo(businessInfo));
    }

    /**
     * 删除图片
     */
    @RequiresPermissions("BusinessInfo:BusinessInfo:remove")
    @Log(title = "图片", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(businessInfoService.deleteBusinessInfoByIds(ids));
    }
}
